package ex3.reversi;


import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import ex3.board.ConfigClass;
import ex3.board.GameBoard;



/**
 * This class represent the GUI.
 *  
 * @author Maxim
 *
 */
public class ReversiGame extends JFrame implements ActionListener{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JButton _onePlayerModeButton;
	private JButton _twoPlayersModeButton;
	private JButton _exitButton;
	
	
	
	public ReversiGame(){
		super("Reversi Game mode");
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.getContentPane().setLayout(new GridLayout(3,1));
		
		this._onePlayerModeButton = new JButton("One player");
		this._twoPlayersModeButton = new JButton("Two players");
		this._exitButton = new JButton("Exit");
		
		this._onePlayerModeButton.addActionListener(this);
		this._twoPlayersModeButton.addActionListener(this);
		this._exitButton.addActionListener(this);
		
		this.getContentPane().add(this._onePlayerModeButton);
		this.getContentPane().add(this._twoPlayersModeButton);
		this.getContentPane().add(this._exitButton);
		
		this.setSize(500,150);
		this.setResizable(true);
		this.setVisible(true);
		
	}
	

	/**
	 * This method invoked when some button pressed on the main menu.
	 * 
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		
		if (e.getSource().equals(this._exitButton))
			System.exit(0);
			
		if (e.getSource().equals(this._onePlayerModeButton)){

			new TurnChoise();
			
			this.dispose();
		}
			
		if (e.getSource().equals(this._twoPlayersModeButton)){
			
			GameBoard c = new GameBoard("REVERSI GAME", ConfigClass.TWO_PLAYER_MODE,ConfigClass.BLACK_PLAYER);
			c.setSize(700, 700);
			c.setVisible(true);
			this.dispose();
			
		}
			
	}
	
	

}
